package edu.fim.presentation.view.model;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import edu.fim.presentation.model.bean.Food;

public class RankTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 9096955106053980225L;

	private String[] columnNames;
	private List<Food> preferences;

	public RankTableModel(String[] columnNames, List<Food> preferences) {
		this.columnNames = columnNames;
		this.preferences = preferences;
	}

	@Override
	public String getColumnName(int column) {
		return columnNames[column];
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	public int getRowCount() {
		return preferences.size();
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		Food preference = preferences.get(rowIndex);
		switch (columnIndex) {
		case 0:
			return preference.getName();
		case 1:
			// TODO: Retornar quantas vezes o alimento foi consumido
			return new Integer(0);
		}
		return null;
	}
}